﻿import com.dmotiko.lib.ControlFrameMovie;
import mx.transitions.easing.Regular;
import mx.transitions.Tween;
/**
 * ...
 * @author sminutoli
 */
import com.dmotiko.meip.*
 class com.dmotiko.meip.ProductosSection extends Section
{
	private var mcContent:MovieClip;
	private var frameControl:MovieClip;
	private var nProducto:Number;
	private var mcRedes:MovieClip;
	private var mcRegulacion:MovieClip;
	private var mcGasoeductos:MovieClip;
	private var mcEquipos:MovieClip;
	private var mcCentrales:MovieClip;
	private var mcGas:MovieClip;
	private var mcObras:MovieClip;
	
	private function initClip():Void {
		super.initClip();
		frameControl = ControlFrameMovie.createControl( this );
		var root = this;
		var btns:Array = [ mcObras, mcRegulacion, mcGasoeductos, mcEquipos, mcCentrales, mcGas, mcRedes ];
		var products:Array = [ 1, 2, 3, 4, 5, 6, 7];
		for ( var i:Number = 0; i < btns.length; i++){
			
			btns[i].producto = products[i];
			btns[i].onRelease = function() {
				root.showProducto( this.producto );
			}
		}
	}
	
	public function showProducto(nProducto:Number):Void {
		//trace("ProductoSection | showProducto= " + nProducto);
		setProducto(nProducto);
		if ( _currentframe == 2 ) gotoAndStop(1);
		gotoAndStop(2);
		FooterClip(Site.getApp().getClips().getFooter()).moveY(620);
	}
	
	public function getProducto():Number {
		return nProducto;
	}
	public function setProducto(nProducto:Number):Void {
		this.nProducto = nProducto;
	}
	
	public function show():Void {
		
		if ( bShowed ) return;
		gotoAndStop(1);
		this._visible = true;
		frameControl.forward( { clip: mcContent, bind: this } );
		registerTween( "fade", new Tween( this,  "_alpha", Regular.easeOut, this._alpha, 100, 0.5, true), false, true );
	}
	
	public function hide():Void {
		if ( !bShowed ) return;
		frameControl.rewind( { clip: mcContent, bind: this } );
		registerTween( "fade", new Tween( this,  "_alpha", Regular.easeOut, this._alpha, 0, 0.5, true), false, true );
	}
	
	
}